﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LMKJ.Classes;

namespace LMKJ
{
    public partial class viewvolunteerdetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int vid = Convert.ToInt32(Request.QueryString["details"]);

                Volunteer v = DatabaseManager.RetrieveVolunteerById(vid);

                if (v != null)
                {
                    vidLbl.Text = vid.ToString();
                    nricLbl.Text = v.Nric;
                    nameLbl.Text = v.Name;
                    dobLbl.Text = v.Dob;
                    genderLbl.Text = v.Gender;
                    addressLbl.Text = v.Address;
                    postalLbl.Text = v.Postal;
                    telephoneLbl.Text = v.Telephone;
                    emailLbl.Text = v.Email;
                    string[] availableDay = v.Available_day.Split(',');
                    for (int i = 0; i < availableDay.Length; i++)
                    {
                        availableDayLbl.Text += availableDay[i];
                        if (i < availableDay.Length - 1)
                        {
                            availableDayLbl.Text += "<br />";
                        }
                    }
                    descriptionLbl.Text = v.Description;
                }
            }
        }

        protected void editBtn_Click(object sender, EventArgs e)
        {
            Response.Redirect("editvolunteer.aspx?details=" + vidLbl.Text);
        }

        protected void backBtn_Click(object sender, EventArgs e)
        {
            Response.Redirect("searchvolunteers.aspx");
        }
    }
}